<template>
  <div class="wrapper">
    <div>
      <input v-model="email" @input="validateEmail" />
      <span>{{ validationMessage }}</span>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "TestFormComponent",
  components: {},
  props: {},
  data() {
    return {
      email: "",
      validationMessage: "",
    };
  },
  watch: {},
  computed: {},
  methods: {
    validateEmail() {
      // 邮箱验证
      let reg = /^.+@.+$/;
      if (!reg.test(this.email)) {
        this.validationMessage = "Invalid email";
      } else {
        this.validationMessage = "";
      }
    },
  },
  created() {
    axios.defaults.baseURL = "http://127.0.0.1:12346";

    axios
      .get("/list")
      .then((response) => {
        console.log(response.data);
      })
      .catch((error) => {
        console.log(error);
      });

    // post 请求
    axios({
      method: "post",
      url: "/CallDevice",
      data: {
        device: "device1111",
        command: "command2222",
        param: "param333",
      },
    })
      .then(function (response) {
        console.log('post 请求');
        console.log(response);
      })
      .catch(function (error) {});
  },
  mounted() {},
};
</script>
<style scoped>
.wrapper {
}
</style>
